<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript" src="${ctx}/scripts/tags/unitedselect/UnitedSelect.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script language="JavaScript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript"	src="${ctx}/scripts/validation/validation.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script language="JavaScript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript">
	var ACTION_URL="${ctx}/charge_charStoChoAction.do?";
	function onSelect(thiz)
	{
		selectId = thiz.options[thiz.selectedIndex].value;
		var url =ACTION_URL+"method=unitedSelect&selectId="+selectId+"&targetId=chargeStaID";
		onChangeSelect(url,selectId,'chargeStaID');
	}
	//新增
	function edit(){
		var url= ACTION_URL + "method=editGenneralCho";
		var pars=$('form1').serialize();
		//校验
		var isTure= $("form1").fireEvent("onSubmit");
		if(isTure){
			checkExistCharSto();
		}
		//ajax提交
		if(isTure && !checkExistCharStoChoResult){
			closeORopenButton();
		//			alert(url);
			var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: 	function (result){
								var obj=findFrame('main');
								obj.reLoadIFrameListWithQuery();
								closeORopenButton();
								ajaxSubmitException(result.responseText);
								windowClose();}
		                    });
		}
	}

	//验证：当某个房号、标准、项目相同时，checkExistCharStoChoGeneralResult改为true,并提示错误信息
	var checkExistCharStoChoResult=false;
	function checkExistCharSto(){

		var url= ACTION_URL + "method=checkExistCharStoChoGeneral";
		//var pars="&houseId="+houseId+"&chargeStaID="+staId+"&chargeItemID="+itemId;
		var pars=$('form1').serialize();

		//ajax提交
			var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars,asynchronous:false, onComplete: 	function (result){
								if(result.responseText=="false"){
									checkExistCharStoChoResult=false;
									//$('selectSpanMessage').style.display="none";
								}else{
									alert($F('houseNumber')+result.responseText);
									checkExistCharStoChoResult=true;
									//$('selectSpanMessage').style.display="";
								}
								}
		                    });

	}

	//关闭或打开按钮事件
	function closeORopenButton(){
		$$('window_footer').disabled= !$$('window_footer').disabled;
		$('btn1_22').disabled= !$('btn1_22').disabled;
		$('btn1_32').disabled= !$('btn1_32').disabled;
	}

	//存放控件的原始值
	var sourceValue="";

	function closeWin(){
		var newValue=$('form1').serialize();
		if(sourceValue==newValue){
			windowClose();
		}else{
			var result=confirm("${key.tipsForCloseWindow}");
			if(result){
				edit();
				return;
			}else{
				windowClose();
			}
		}
	}

	function init(){
		sourceValue=$('form1').serialize();
	}
</script>
</head>

<body onload="init();">
<form action="" id="form1" class="required-validate" method="post">
<input name="keyword" value="${chargeStaChoVO.keyword}" type="hidden">
<input name="houseId" value="${chargeStaChoVO.houseId}" type="hidden">
<input name="houseNumber" value="${chargeStaChoVO.houseNumber}" type="hidden">
<input name="oldChargeItemID" value="${chargeStaChoVO.chargeItemID}" type="hidden">
<input name="oldChargeStaID" value="${chargeStaChoVO.chargeStaID}" type="hidden">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><span class="window_head_intext"><img src="${ctx}/images/ico_Advance.gif" align="absmiddle">&nbsp;${key.modiTitle}</span></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>

  <tr>
    <td class="content">
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="outtable">
  <tr>
    <td>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
        <td class="aux_outtable_color">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>

		<table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
         <tr>
            <td width="13%" class="aux_intable_tdwidwidth">${key.chargeItem}：</td>
            <td width="13%" class="aux_intable_tdkeyword">
    							<pms:unitedSelect id="chargeItemID"
											name="chargeItemID"
											actionName=""
											targetId="chargeStaID"
											dataList="${chargeItemList}"
											optionLabel="itemName"
											optionValue="keyword"
											onChange="onSelect(this)"
											value="${chargeStaChoVO.chargeItemID}"
											selectText="${key.pleaseSelect}"
											className="required"
											>
	              						</pms:unitedSelect>  </td>
            <td class="aux_intable_tdwidwidth">${key.chargeSta}：</td>
            <td class="aux_intable_tdkeyword">
						            		<pms:unitedSelect
												id="chargeStaID"
												name="chargeStaID"
												dataList="${chargeStaList}"
												optionLabel="staName"
												optionValue="keyword"
												selectText="${key.pleaseSelect}"
												value="${chargeStaChoVO.chargeStaID}"
												className="required"
												>
											</pms:unitedSelect><span id="selectSpanMessage"
																			style="display:none;margin-left:10px;"> <img
																			src="${ctx}/images/validate/ErrorWarn.gif" width="15"
																			height="15" style="cursor: hand" alt="${key.checkTips}"
																			onClick="alert('${key.checkTips}');" /> </span>
			</td>
            </tr>

      </table>
	  </td>
        </tr>
      </table>
	 </td>
  </tr>
    </table></td>
	  </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2" class="window_footer">      <table border="0" cellspacing="0" cellpadding="0">
        <tr>
		  <td>&nbsp;</td>
		  <td class="btn_between_space">&nbsp;</td>
		  <td><table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td class="buttonOffLeft" id="btn1_21"></td>
                <td class="buttonOffMiddle" id="btn1_22" onClick="edit();" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onBlur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.save}</td>
                <td class="buttonOffRight" id="btn1_23"></td>
              </tr>
          </table></td>
          <td class="btn_between_space"></td>
          <td><table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td class="buttonOffLeft" id="btn1_31"></td>
                <td class="buttonOffMiddle" id="btn1_32" onClick="closeWin();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom"> ${key.close }</td>
                <td class="buttonOffRight" id="btn1_33"></td>
              </tr>
          </table></td>
        </tr>
          </table>
      <p>&nbsp;</p></td>
  </tr>
</table>
</form>
</body>
</html>